package com.njtoyo.taxi.admin.utils;

import com.relops.snowflake.Snowflake;

import java.util.Calendar;
import java.util.Date;

public class Identifier {
    private String machineId;

    public Identifier(String machineId){
        this.machineId = machineId;
    }

    public String generate(){
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        int ms = c.get(Calendar.MILLISECOND);
        Snowflake s = new Snowflake(ms);
        long id = s.next();
        return this.machineId.toUpperCase() + String.valueOf(id);
    }

}
